package com.kelvin.paopao.module.peisong.mypeisong;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.flyco.tablayout.SlidingTabLayout;
import com.kelvin.paopao.R;
import com.kelvin.paopao.module.base.BaseActivity;
import com.kelvin.paopao.module.main.date.mydate.myask.MyAskDateFragment;
import com.kelvin.paopao.module.main.date.mydate.mypublish.MyPublishDateFragment;
import com.kelvin.paopao.module.peisong.mypeisong.myorder.MyOrderFragment;
import com.kelvin.paopao.module.peisong.mypeisong.myrequestpeisong.MyRequestPeisongFragment;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * Created by Administrator on 2017/5/11.
 */

public class MyPeisongActivity extends BaseActivity {

    @BindView(R.id.stl)
    SlidingTabLayout stl;
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.viewPager)
    ViewPager viewPager;

    private boolean isMyAsk;

    private final String[] mTitles = {
            "我的订单", "报名配送"
    };

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_my_date;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initViews() {

        isMyAsk = getIntent().getBooleanExtra("isMyAsk", false);

        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        MyOrderFragment orderFragment = MyOrderFragment.newInstance();
        MyRequestPeisongFragment myRequestPeisongFragment
                = MyRequestPeisongFragment.newInstance();

        ArrayList<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(orderFragment);
        fragmentList.add(myRequestPeisongFragment);

        stl.setViewPager(viewPager, mTitles, this, fragmentList);

        if (isMyAsk) {
            viewPager.setCurrentItem(1);
        }
    }

    @Override
    protected void updateViews(boolean isRefresh) {

    }

    public static void launch(Context context) {
        Intent intent = new Intent(context, MyPeisongActivity.class);
        context.startActivity(intent);
    }
}
